package com.concise.appapi.controller;

import com.concise.appapi.service.SearchService;
import com.concise.appapi.service.model.TheArticleListsModel;
import com.initialize.pub.pojo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2020/3/7
 * Time: 2:51 下午
 * Description:
 * @author jane
 */

@CrossOrigin
@Api(tags = "搜索API")
@RestController
@RequestMapping(value = "/search")
public class SearchController {

    final
    SearchService searchService;

    public SearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    @ApiOperation(value = "用于首页搜索")
    @PostMapping("/{key}")
    public Result homeSearch(@PathVariable String key) {
        List<TheArticleListsModel> theArticleListsModelList = searchService.homeSearch(key);
        return Result.success(theArticleListsModelList);
    }
}
